// 2013-8-1下午12:47:38  net.betou.trade.main.manager.UserMng.java

package net.betou.trade.main.manager;

import java.util.List;

import net.betou.common.page.Pagination;
import net.betou.common.security.exception.BadCredentialsException;
import net.betou.common.security.exception.UsernameNotFoundException;
import net.betou.pojo.Report;
import net.betou.trade.entity.main.AgentAndAdmins;
import net.betou.trade.entity.main.User;
import net.betou.trade.entity.main.UserExt;

/**
 * 
 * @author 叶装装
 */
public interface UserMng{
	
	public List< Report > findMonthReport( String month );
	
	public List< Report > findDayReport( String day );
	
	public List< String > findDayReportChoice( String year );
	
	public List< String > findMonthReportChoice( String year );
	
	public List< String > findYearReportChoice( );
	
	public User save( AgentAndAdmins admin, Integer groupId, String ip, User bean, UserExt ext );

	/**
	 * 查找自己的User
	 * 
	 * @param userid
	 * @param adminId
	 * @return
	 */
	public User findMyUser( Integer userid, Integer adminId, Boolean system );

	/**
	 * 更新
	 * 
	 * @param user
	 * @param ext
	 * @return
	 */
	public User update(  Byte status, String expireDate, Integer groupId, String email, String password, String mobile, Boolean disabled, String demoAccount, String demoAccountPwd, String firmAccount, String firmAccountPwd, User user, UserExt ext );

	/**
	 * 根据ID查找
	 * 
	 * @param id
	 *            ID
	 * @return
	 */
	public User findById( Integer id );

	/**
	 * 根据用户名查找
	 * 
	 * @param username
	 *            用户名
	 * @return
	 */
	public User findByUsername( String username );

	/**
	 * 批量删除
	 * 
	 * @param ids
	 *            传递的ID数组
	 * @return
	 */
	public User [ ] deleteByIds( Integer [ ] ids );

	/**
	 * 更新登录
	 * 
	 * @param userId
	 * @param ip
	 */
	public void updateLoginInfo( Integer userId, String ip );

	/**
	 * 登录
	 * 
	 * @param username
	 * @param password
	 * @param ip
	 * @return
	 * @throws UsernameNotFoundException
	 * @throws BadCredentialsException
	 */
	public User login( String username, String password, String ip ) throws UsernameNotFoundException, BadCredentialsException;

	/**
	 * 用户名是否存在
	 * 
	 * @param username
	 * @return
	 */
	public boolean userNameNotExist( String username );

	/**
	 * email 是否存在
	 * 
	 * @param email
	 * @return
	 */
	public boolean emailNotExist( String email );

	/**
	 * 手机号码是否存在
	 * 
	 * @param mobile
	 * @return
	 */
	public boolean mobileNotExist( String mobile );
	
	public boolean demoAccountExit( String demoAccount );
	
	public boolean firmAccountExit( String firmAccount );

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	public User deleteById( Integer id );

	/**
	 * 查找居间商列表
	 * 
	 * @return
	 */
	public Pagination getPage( AgentAndAdmins admin, String searchProperty, String searchValue, String orderProperty, String orderDirection, int pageNo, int pageSize, String filterStatus );

	
	public List< String > getMobileList( Integer adminId, String  groups);
	
	public List< String > getMobileList( AgentAndAdmins admin, String groups );
	
	// 根据业务员当前admin, 直接获取上级的ID
	// 判断当前用户的admin, 是否是机构或者代理商, 如果是机构， 直接返回。 如果是代理商，则需要查找机构
	// 如果只是普通的管理员， 则要先查询上级代理商和机构的ID
	// 另外，还需要判断当前的面向用户组
	
	public List< Integer > getSearchId( User user );
	
	public AgentAndAdmins getProxyOrAgency( User user );
}
